package com.xbongbong.saas.model.impl;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.elasticsearch.model.PaasEsModel;
import com.xbongbong.paas.elasticsearch.pojo.dto.InsertDTO;
import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.enums.IndexTypeEnum;
import com.xbongbong.paas.help.subform.TransferSubFormHelper;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.pro.constant.ElasticConstant;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.ParameterConstant;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.domain.dao.MarketActivityUserDao;
import com.xbongbong.saas.domain.entity.MarketActivityUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import com.xbongbong.saas.enums.subform.CustomerTeamEnum;
import com.xbongbong.saas.enums.subform.PaymentSheetTeamEnum;
import com.xbongbong.saas.model.MarketActivityUserModel;
import org.apache.commons.collections4.CollectionUtils;
import org.elasticsearch.action.support.WriteRequest;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;


/**
 * @author chunyang.qin
 * @version v1.0
 * @date 2020/11/4 10:20
 * @since v1.0
 */

@Component
@Service("marketActivityUserModel")
public class MarketActivityUserModelImpl implements MarketActivityUserModel {
    @Resource
    private MarketActivityUserDao marketActivityUserDao;
    @Resource
    private PaasEsModel paasEsModel;
    @Resource
    private TransferSubFormHelper transferSubFormHelper;

    @Override
    public Integer insert(MarketActivityUserEntity marketActivityUserEntity) throws XbbException {
        Long now = DateTimeUtil.getInt();
        marketActivityUserEntity.setAddTime(now);
        marketActivityUserEntity.setUpdateTime(now);
        Integer result = marketActivityUserDao.insert(marketActivityUserEntity);
        PaasFormDataEntity paasFormDataEntity = transferSubFormHelper.transferUserTeamToFormData(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM, marketActivityUserEntity);
        InsertDTO insertDTO = paasEsModel.getSaveDTO(paasFormDataEntity, IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
        paasEsModel.insert(insertDTO);
        //paasEsModel.insert(marketActivityUserEntity,IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM,marketActivityUserEntity.getCorpid(),marketActivityUserEntity.getId(),marketActivityUserEntity.getDataId());
        return result;
    }

    @Override
    public Integer update(MarketActivityUserEntity marketActivityUserEntity) throws XbbException {
        Long now = DateTimeUtil.getInt();
        marketActivityUserEntity.setUpdateTime(now);
        Integer result = marketActivityUserDao.update(marketActivityUserEntity);
        if (Objects.equals(1, result)) {
            PaasFormDataEntity paasFormDataEntity = transferSubFormHelper.transferUserTeamToFormData(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM, marketActivityUserEntity);
            InsertDTO saveDTO = paasEsModel.getSaveDTO(paasFormDataEntity, IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
            paasEsModel.update(saveDTO);
        }
//        paasEsModel.update(marketActivityUserEntity,IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM,marketActivityUserEntity.getCorpid(),marketActivityUserEntity.getId(),marketActivityUserEntity.getDataId());
        return result;
    }

    @Override
    public List<MarketActivityUserEntity> findEntitys(Map<String, Object> param) {
        return marketActivityUserDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return marketActivityUserDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer save(MarketActivityUserEntity marketActivityUserEntity) throws XbbException {
        if (marketActivityUserEntity.getId() == null || marketActivityUserEntity.getId().equals(0L)) {
           return insert(marketActivityUserEntity);
        }
        return update(marketActivityUserEntity);
    }

    @Override
    public MarketActivityUserEntity getByKey(Long key, String corpid) {
        return marketActivityUserDao.getByKey(key, corpid);
    }

    @Override
    public List<String> getMarketActivityUserIdList(String corpid, List<Long> marketActivityIds, Integer isMain) {
        return marketActivityUserDao.getMarketActivityUserIdList(corpid,marketActivityIds,isMain);
    }

    @Override
    public List<MarketActivityUserEntity> getMarketActivityUserList(String corpid, Long marketActivityId, Integer isMain) {
        Map<String, Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put(StringConstant.CORPID, corpid);
        param.put(StringConstant.DEL, DelEnum.NORMAL.getDel());
        param.put(StringConstant.DATA_ID, marketActivityId);
        param.put("isMain", isMain);
        return findEntitys(param);
    }

    @Override
    public List<Long> getDataIdList(String corpid, Integer isMain, List<String> userId) {
        return marketActivityUserDao.getDataIdList(corpid,isMain,userId);
    }

    @Override
    public void batchUpgrade(String corpid, List<MarketActivityUserEntity> customerUsers, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException{
        marketActivityUserDao.batchUpgrade(corpid, customerUsers);
        List<InsertDTO> insertList = new ArrayList<>();
        for (MarketActivityUserEntity entity : customerUsers){
            InsertDTO insertDTO = new InsertDTO();
            insertDTO.setEsId(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "_" + corpid + "_" + entity.getId());
            insertDTO.setParent(corpid + "_" + entity.getDataId());
            Map<String, Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            JSONObject object = new JSONObject();
            object.put(CustomerTeamEnum.IS_MAIN.getDataAttr(), 1);
            map.put(StringConstant.JSON_DATA, object);
            map.put("updateTime", DateTimeUtil.getInt());
            insertDTO.setSource(map);
            insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
            insertList.add(insertDTO);
        }
        paasEsModel.updateBatch(insertList, refreshPolicy);
    }

    @Override
    public void deleteBatch(String corpid, List<MarketActivityUserEntity> customerUsers, WriteRequest.RefreshPolicy refreshPolicy, Integer del) throws XbbException {
        if (CollectionUtils.isEmpty(customerUsers)) {
            return;
        }
        List<Long> removeIdList = new ArrayList<>();
        List<InsertDTO> insertDTOList = new ArrayList<>();
        for (MarketActivityUserEntity entity : customerUsers){
            removeIdList.add(entity.getId());
            InsertDTO insertDTO = new InsertDTO();
            insertDTO.setEsId(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "_" + corpid + "_" + entity.getId());
            insertDTO.setParent(corpid + "_" + entity.getDataId());
            Map<String, Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            map.put("del", del);
            map.put(StringConstant.UPDATE_TIME, DateTimeUtil.getInt());
            insertDTO.setSource(map);
            insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
        }
        marketActivityUserDao.batchDeleteById(corpid,removeIdList, del);
        paasEsModel.updateBatch(insertDTOList, refreshPolicy);
    }

    @Override
    public void insertBatch(List<MarketActivityUserEntity> customerUserEntityList, boolean isImport) throws XbbException{
        marketActivityUserDao.insertBatch(customerUserEntityList);

        List<PaasFormDataEntity> paasFormDataEntities = transferSubFormHelper.transferUserTeamToFormDataList(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM, customerUserEntityList);
        List<InsertDTO> insertDTOList = new ArrayList<>();
        for (PaasFormDataEntity paasFormDataEntity : paasFormDataEntities) {
            insertDTOList.add(paasEsModel.getSaveDTO(paasFormDataEntity, IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM));
        }
//        for (MarketActivityUserEntity marketActivityUserEntity : customerUserEntityList) {
//            InsertDTO insertDTO = new InsertDTO();
//            insertDTO.setWaitUntil(WriteRequest.RefreshPolicy.NONE);
//            insertDTO.setEsId(marketActivityUserEntity.getCorpid() + "_" + marketActivityUserEntity.getId());
//            insertDTO.setParent(marketActivityUserEntity.getCorpid() + "_" + marketActivityUserEntity.getDataId());
//            insertDTO.setSource(BeanUtil.convertBean2Map(marketActivityUserEntity, false, true));
//            insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
//            insertDTOList.add(insertDTO);
//        }
        if (isImport) {
            paasEsModel.insertBatch(insertDTOList, WriteRequest.RefreshPolicy.NONE);
        } else {
            paasEsModel.insertBatch(insertDTOList);
        }

    }


    @Override
    public void batchDeleteByMarketActivityId(String corpid, List<Long> customerIdIn, List<String> userIdList) throws XbbException{
        Map<String,Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        map.put("corpid",corpid);
        map.put("del",0);
        map.put("customerIdIn",customerIdIn);
        map.put("userIdIn",userIdList);
        List<MarketActivityUserEntity> customerUserEntityList = findEntitys(map);
        marketActivityUserDao.batchDelete(corpid,customerIdIn,userIdList);
        for (MarketActivityUserEntity entity : customerUserEntityList){
            paasEsModel.delete(entity.getId(), corpid, IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM,entity.getDataId());
        }
    }

    @Override
    public void batchDeleteTeam(String corpid, List<Long> customerIdIn, List<String> userIdList, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException{
        Map<String,Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        map.put("corpid",corpid);
        map.put("del",0);
        map.put("customerIdIn",customerIdIn);
        map.put("userIdIn",userIdList);
        List<MarketActivityUserEntity> customerUserEntityList = findEntitys(map);
        marketActivityUserDao.batchDelete(corpid,customerIdIn,userIdList);
        List<InsertDTO> insertDTOList = new ArrayList<>();
        for (MarketActivityUserEntity entity : customerUserEntityList){
            InsertDTO insertDTO = new InsertDTO();
            insertDTO.setEsId(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "_" + corpid + "_" + entity.getId());
            insertDTO.setParent(corpid + "_" + entity.getDataId());
            Map<String, Object> sourceMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            sourceMap.put(ParameterConstant.DEL, DelEnum.DELETE.getDel());
            sourceMap.put(StringConstant.UPDATE_TIME, DateTimeUtil.getInt());
            insertDTO.setSource(sourceMap);
            insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
            insertDTOList.add(insertDTO);
        }
        paasEsModel.updateBatch(insertDTOList, refreshPolicy);
    }

    @Override
    public Map<Long, Set<String>> batchDeleteById(String corpid, List<Long> removeIdList, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException{
        Map<String,Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        map.put("corpid",corpid);
        map.put("del",0);
        map.put("idIn",removeIdList);
        List<MarketActivityUserEntity> customerUserEntityList = findEntitys(map);
        marketActivityUserDao.batchDeleteById(corpid,removeIdList, DelEnum.DELETE.getDel());
        List<InsertDTO> insertDTOList = new ArrayList<>();
        Map<Long, Set<String>> marketActivityUserMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for (MarketActivityUserEntity entity : customerUserEntityList){
            Set<String> orDefault = marketActivityUserMap.getOrDefault(entity.getDataId(), new HashSet<>());
            orDefault.add(entity.getUserId());
            marketActivityUserMap.put(entity.getDataId(),orDefault);
            InsertDTO insertDTO = new InsertDTO();
            insertDTO.setEsId(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "_" + corpid + "_" + entity.getId());
            insertDTO.setParent(corpid + "_" + entity.getDataId());
            insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
            insertDTO.setIndex(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getIndex());
            insertDTO.setType(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType());
            Map<String,Object> sourceMap = new HashMap<>();
            sourceMap.put(StringConstant.UPDATE_TIME, DateTimeUtil.getInt());
            sourceMap.put(StringConstant.DEL,DelEnum.DELETE.getDel());
            insertDTO.setSource(sourceMap);
            insertDTOList.add(insertDTO);
//            paasEsModel.delete(entity.getId(), corpid, IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM,entity.getDataId());
        }
        paasEsModel.updateBatch(insertDTOList, refreshPolicy);
        return marketActivityUserMap;
    }

    @Override
    public void delete(MarketActivityUserEntity marketActivityUser) throws XbbException{
        marketActivityUser.setDel(1);
        marketActivityUser.setUpdateTime((long) DateUtil.getInt());
        marketActivityUserDao.update(marketActivityUser);
        paasEsModel.delete(marketActivityUser.getId(), marketActivityUser.getCorpid(), IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM, marketActivityUser.getDataId());
//        paasEsModel.update(marketActivityUser,IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM,marketActivityUser.getCorpid(),marketActivityUser.getId(),marketActivityUser.getDataId());
    }

    @Override
    public List<UserTeamEntity> findBaseEntitys(Map<String, Object> map) {
        return marketActivityUserDao.findBaseEntitys(map);
    }

    @Override
    public Integer updateBatch(List<MarketActivityUserEntity> list, String corpid) throws XbbException{
        Integer result = marketActivityUserDao.updateBatch(list, corpid);
        List<PaasFormDataEntity> paasFormDataEntities = transferSubFormHelper.transferUserTeamToFormDataList(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM, list);
        List<InsertDTO> insertList = new ArrayList<>();
        for (PaasFormDataEntity paasFormDataEntity : paasFormDataEntities) {
            insertList.add(paasEsModel.getSaveDTO(paasFormDataEntity, IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM));
        }
//        for (MarketActivityUserEntity entity : list){
//            InsertDTO insertDTO = new InsertDTO();
//            insertDTO.setEsId(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "_" + corpid + "_" + entity.getId());
//            insertDTO.setParent(corpid + "_" + entity.getDataId());
//            Map<String, Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
//            map.put("del", -1);
//            map.put("updateTime", DateTimeUtil.getInt());
//            insertDTO.setSource(map);
//            insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
//            insertList.add(insertDTO);
//        }
        paasEsModel.updateBatch(insertList);
        return result;
    }


    @Override
    public void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> userTeamEntityList, Integer isMain, Integer del) throws XbbException {
        marketActivityUserDao.batchUpdateByIdIn(corpid, dataIdIn, isMain, del);
        List<InsertDTO> insertList = new ArrayList<>();
        for (UserTeamEntity userTeamEntity : userTeamEntityList) {
            String route = corpid + "_" + userTeamEntity.getDataId();
            InsertDTO insertDTO = new InsertDTO();
            insertDTO.setEsId(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "_" + corpid + "_" + userTeamEntity.getId());
            insertDTO.setParent(route);
            Map<String, Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            if (Objects.nonNull(isMain)) {
                JSONObject object = new JSONObject();
                object.put(CustomerTeamEnum.IS_MAIN.getDataAttr(), isMain);
                map.put(StringConstant.JSON_DATA, object);
            }
            if (Objects.nonNull(del)) {
                map.put(ParameterConstant.DEL, del);
            }
            map.put(FieldTypeEnum.UPDATETIME.getAlias(), DateTimeUtil.getInt());
            String relations = "{\"name\":\"" + IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "\",\"parent\":\"" + route  +"\"}";
            map.put(ElasticConstant.MY_JOIN_FIELD, JSONObject.parse(relations));
            insertDTO.setSource(map);
            insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
            insertList.add(insertDTO);
        }
        paasEsModel.updateBatch(insertList);
    }

    @Override
    public void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> userTeamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException {
        marketActivityUserDao.batchUpdateByIdIn(corpid, dataIdIn, isMain, del);
        List<InsertDTO> insertList = new ArrayList<>();
        for (UserTeamEntity userTeamEntity : userTeamEntityList) {
            InsertDTO insertDTO = new InsertDTO();
            insertDTO.setEsId(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "_" + corpid + "_" + userTeamEntity.getId());
            insertDTO.setParent(corpid + "_" + userTeamEntity.getDataId());
            Map<String, Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            if (Objects.nonNull(isMain)) {
                JSONObject object = new JSONObject();
                object.put(CustomerTeamEnum.IS_MAIN.getDataAttr(), isMain);
                map.put(StringConstant.JSON_DATA, object);
            }
            if (Objects.nonNull(del)) {
                map.put(ParameterConstant.DEL, del);
            }
            map.put(FieldTypeEnum.UPDATETIME.getAlias(), DateTimeUtil.getInt());
            insertDTO.setSource(map);
            insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
            insertList.add(insertDTO);
        }
        paasEsModel.updateBatch(insertList, refreshPolicy);
    }

    /**
     *
     * @Description: 编辑团队成员标签
     * @param marketActivityUserEntity
     * @return: void
     * @Author: shen.yang
     * @Date: 2022/1/17  14:20
     */
    @Override
    public void editLabel(MarketActivityUserEntity marketActivityUserEntity) throws XbbException {
        updateFormTeam(marketActivityUserEntity);
    }

    /**
     * 更新协同人可编辑权限
     *
     * @param marketActivityUserEntity
     */
    @Override
    public void updateEditFormPer(MarketActivityUserEntity marketActivityUserEntity) throws XbbException {
        updateFormTeam(marketActivityUserEntity);
    }


    private void updateFormTeam(MarketActivityUserEntity marketActivityUserEntity) throws XbbException {
        Long updateTime = DateTimeUtil.getInt();
        marketActivityUserEntity.setUpdateTime(updateTime);
        marketActivityUserDao.update(marketActivityUserEntity);
        InsertDTO insertDTO = new InsertDTO();
        String corpid = marketActivityUserEntity.getCorpid();
        insertDTO.setEsId(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "_" + corpid + "_" + marketActivityUserEntity.getId());
        insertDTO.setParent(corpid + "_" + marketActivityUserEntity.getDataId());
        Map<String, Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        map.put("updateTime", updateTime);
        insertDTO.setSource(map);
        insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
        paasEsModel.update(insertDTO);
    }

    /**
     * 批量更新团队的人员为协同人身份以及协同人的可编辑权限
     *
     * @param corpid
     * @param dataIdIn
     * @param teamEntityList
     * @param isMain
     * @param needThrow
     * @throws XbbException
     */
    @Override
    public void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow) throws XbbException {
        batchUpdateCoAndPerByUserIdIn(corpid, idIn, teamEntityList, isMain, needThrow, WriteRequest.RefreshPolicy.WAIT_UNTIL);
    }

    @Override
    public void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException {
        Integer formPermission = teamEntityList.get(BasicConstant.ZERO).getFormPermission();
        marketActivityUserDao.batchUpdateCoAndPerByUserIdIn(corpid, idIn, isMain, formPermission);
        List<InsertDTO> insertList = new ArrayList<>();
        for (UserTeamEntity userTeamEntity : teamEntityList) {
            InsertDTO insertDTO = new InsertDTO();
            insertDTO.setEsId(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM.getType() + "_" + corpid + "_" + userTeamEntity.getId());
            insertDTO.setParent(corpid + "_" + userTeamEntity.getDataId());
            Map<String, Object> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
            if (Objects.nonNull(isMain)) {
                JSONObject object = new JSONObject();
                object.put(PaymentSheetTeamEnum.IS_MAIN.getDataAttr(), isMain);
                map.put(StringConstant.JSON_DATA, object);
            }
            map.put(FieldTypeEnum.UPDATETIME.getAlias(), DateTimeUtil.getInt());
            insertDTO.setSource(map);
            insertDTO.setIndexTypeEnum(IndexTypeEnum.IDX_SAAS_MARKET_ACTIVITY_TEAM);
            insertList.add(insertDTO);
        }
        paasEsModel.updateBatch(insertList, refreshPolicy, needThrow);
    }


}